package com.lagou.base;

import com.alibaba.fastjson.JSONObject;

public enum StatusCode {
    SUCCESS(0,"success"),FAIL(1,"fail");
    //定义属性
    private int code;
    private String massage;

    StatusCode() {
    }

    StatusCode(int code, String massage) {
        this.code = code;
        this.massage = massage;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }
//重写ToString(),将枚举对象转换为JSON
    @Override
    public String toString() {

        JSONObject object=new JSONObject();
        object.put("status",code);
        object.put("msg",massage);
        return object.toString();
    }
}
